/*
baidu RandomAcessFile的用法，给出案例
 */
package day9.Exer;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

public class Exer9 {
    public static void main(String[] args) {
        RandomAccessFile raf=null;
        try {
            raf=new RandomAccessFile("E:\\作业\\f.txt","rw");
            raf.writeBytes("This is a dog");
            raf.seek(2);
            String str;
            while((str=raf.readLine())!=null){
                System.out.println(str);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            if(raf!=null){
                try {
                    raf.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
